package com.jielihaofeng.net;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author Johnnie Wind
 * @description
 * @date 2021/11/29 14:16
 */
public class InetAddressTest {
    public static void main(String[] args) throws UnknownHostException {
        InetAddress address = InetAddress.getByName("localhost");
        String hostName = address.getHostName();
        String hostAddress = address.getHostAddress();
        System.out.println(hostName);
        System.out.println(hostAddress);
    }
}
